<?php
/* Deatils of Coach */
include("general_include.php");
$page_name="studentdetails.php";
$action=$_REQUEST['action'];

include "top.php";

//##################### Added By Chandan
if($_REQUEST['student_id']!='') $_SESSION['student_id'] = $_REQUEST['student_id'];
if($_REQUEST['student_id']=='') $_REQUEST['student_id'] = $_SESSION['student_id'];
if($_REQUEST['action']!='') $_SESSION['student_action'] = $_REQUEST['action'];
if($_REQUEST['action']=='') $_REQUEST['action'] = $_SESSION['student_action'];
//if($_REQUEST['price']!='') $_SESSION['student_price'] = $_REQUEST['price'];
//if($_REQUEST['price']=='') $_REQUEST['price'] = $_SESSION['student_price'];

//if($_REQUEST['languages']!='') $_SESSION['student_languages'] = $_REQUEST['languages'];
//if($_REQUEST['languages']=='') $_REQUEST['languages'] = $_SESSION['student_languages'];
/*if($_REQUEST['availabilitys']!='') $_SESSION['student_availabilitys'] = $_REQUEST['availabilitys'];
if($_REQUEST['availabilitys']=='') $_REQUEST['availabilitys'] = $_SESSION['student_availabilitys'];
*/
//if($_REQUEST['games']!='') $_SESSION['student_games'] = $_REQUEST['games'];
//if($_REQUEST['games']=='') $_REQUEST['games'] = $_SESSION['student_games'];
//###################### Added By Chandan

$student_id = $_REQUEST['student_id']; 

function findvalue($table,$fld_name,$fld_value,$find_value)
{
     if($fld_value=='')
			return false;
			
		$SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
		$SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
		return $SelectType[0];
}	

$StudentSql="SELECT * FROM ".TABLEPREFIX."_user where user_id='$student_id'";
$StudentArr=$UserManagerObjAjax->GetRecords("Row",$StudentSql);

$StudentArr['name']=show_to_control($StudentArr['name']);
$StudentArr['about']=stripslashes($StudentArr['user_about']);
$StudentArr['desc']=stripslashes($StudentArr['description']);
$StudentArr['country']=findvalue(TABLEPREFIX."_country","country_id",$StudentArr['country'],"country_name");
$avail_type = explode(",",$StudentArr['availability_type']);
if($avail_type[1] == '')
{
  if($avail_type[0]=='O')
   $StudentArr['availability_type'] = 'Online';
  if($avail_type[0]=='L') 
  {
   $StudentArr['availability_type'] = 'Local meet-up';
   $StudentArr['avail_local'] = 'Y'; 
  }  
}
else
{
  $StudentArr['availability_type'] = 'Online , Local meet-up';
  $StudentArr['avail_local'] = 'Y'; 
}    

$StudentArr['availability_country'] = findvalue(TABLEPREFIX."_country","country_id",$StudentArr['availability_country'],"country_name");

$Clanguage = explode(",",$StudentArr['language_ids']);
	$language='';
	for($l=0;$l<count($Clanguage);$l++)
	{
	   if($Clanguage[$l]<>'')
	    $language .=findvalue(TABLEPREFIX."_language","language_id",$Clanguage[$l],"language_name").' , ';
	}
$StudentArr['language']=substr($language,0,-2);
    if($StudentArr['availability_type'] == 'O')
	  $StudentArr['availability_type'] = 'Online'; 
	if($StudentArr['availability_type'] == 'L')
	  $StudentArr['availability_type'] = 'Local meet-up';  

$studentGame = "SELECT * FROM ".TABLEPREFIX."_user_game where user_id='$student_id' and is_active='Y'";
$StudentGameArr = $UserManagerObjAjax->GetRecords("All",$studentGame);
$Numstudentgame=count($StudentGameArr);
for($g=0;$g<$Numstudentgame;$g++)
{
   $StudentGameArr[$g]['game'] = findvalue(TABLEPREFIX."_game","game_id",$StudentGameArr[$g]['game_id'],"game_name");
   $StudentGameArr[$g]['experience'] = stripslashes($StudentGameArr[$g]['experience']);
}	

  //  $studentGame = "SELECT * FROM ".TABLEPREFIX."_user_game WHERE user_id='$student_id'";
	//$StudentGameArr = $UserManagerObjAjax->GetRecords("All",$studentGame);
//	for($g=0;$g<count($StudentGameArr);$g++)
//	{
	 // $game .= findvalue(TABLEPREFIX."_game","game_id",$StudentGameArr[$g]['game_id'],"game_name").",";
	//} 
//$StudentArr['game'] = substr($game,0,-1);	  

/*
$game_id[] = $_REQUEST['games'];
$availability[] = $_REQUEST['availabilitys'];
$language_id[] = $_REQUEST['languages'];
*/

$game_id = explode(",",$_REQUEST['games']);
$availability = explode(",",$_REQUEST['availabilitys']);
$language_id = explode(",",$_REQUEST['languages']);

$price = $_REQUEST['price'];
if($game_id == '')
  $game_id  = array();
if($availability == '')
	$availability = array();   
if($language_id == '')
	$language_id = array();
if($price == '')
	$price = '0;100';


$smarty->assign('language_id',$language_id);
$smarty->assign('game_id',$game_id);
$smarty->assign('availability',$availability);
$smarty->assign('price',$price);

$smarty->assign('StudentArr',$StudentArr);
$smarty->assign('StudentGameArr',$StudentGameArr);
$smarty->assign('student_id',$student_id);
$smarty->assign('page_name',$page_name);
include "student_leftpanel.php";
$smarty->display('studentdetails.tpl');
if($IsProcess <> 'Y')
	 include "footer.php";
?>